#!/usr/bin/env python

#################################################################################
#
# Copyright (c) 2006 Michigan State University
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#################################################################################

#################################################################################
#
#	Author:
#		Nathan Collins <npcollins@gmail.com>
#
#################################################################################

from oaicookie import *
from terms import *

# show search history
def showHistory(retAsStr = 0):
	list = getCookieList('searchHistory')
	list.reverse()
	num = 0
	final = ''
	for terms in list:
		if len(terms.strip()) > 0:
			url = '/search.py?s=' + urls(terms)
			if num % 2 == 0:
				nummod = ''
			else:
				nummod = ' badurl'
			num += 1
			final += "<div class=\"historyResult%s\">&nbsp;<a href=\"%s\" class=\"noUL\">%s</a>&nbsp;</div>" % (nummod,url,shorten(terms,80))
	if retAsStr != 0:
		return final
	else:
		print final

# eof

